

/****************************************************/
/*                                                                                
/* Create Table with all courts and number of cases */
/*                                                                                
/****************************************************/



libname raw 'G:\Data\Rawdata\707677';

libname common 'G:\Data\Workdata\707677\Common\01Data\01SAS';




/*******************/
/* Load our sample */
/*******************/


data automat;

set common.ivs;

keep pnr court pyear;

run;



/***********************************/
/* Count Number of Cases per COurt */
/***********************************/


proc summary data=automat;

class court;

output out= stats

n(pyear)=obs;

run;



/****************/
/* Polish Table */
/****************/



data stats;

set stats;

drop _type_ _freq_;

if court~='';

run;



data first;

set stats;

id=_n_;

rename court=fcourt;

rename obs=fobs;

if _n_<37;

run;



data second;

set stats;

rename court=scourt;

rename obs=sobs;

if _n_>36;

run;




data second;

set second;

id=_n_;

run;



proc sql;

create table courts as select a.fcourt, a.fobs, b.scourt, b.sobs

from first as a left join

second as b on

a.id=b.id;

quit;




/* Export to Excel */



proc export data=courts outfile='G:\Data\Workdata\707677\Common\03Output\03Tables\courts.xls' dbms=excel5 replace;

run;






proc datasets library=work nolist kill;

quit;









